package com.usfuture.techanly.view
{
	import com.usfuture.Canvas;
	import com.usfuture.ICallRequest;
	import com.usfuture.ICanvas;
	import com.usfuture.chart.IChart;
	import com.usfuture.chart.techanly.AbstractTechProperty;
	import com.usfuture.chart.techanly.ITechAnlyChart;
	import com.usfuture.chart.techanly.TechPropertyFactory;
	import com.usfuture.chart.techanly.amount.AmountChart;
	import com.usfuture.chart.techanly.line.LineChart;
	import com.usfuture.chart.techanly.scale.ScaleChart;
	import com.usfuture.customComponent.ZoomButton;
	import com.usfuture.event.BusyMaskEvent;
	import com.usfuture.event.DataEvent;
	import com.usfuture.insInfo.entity.InsInfo;
	import com.usfuture.techanly.entity.Line;
	import com.usfuture.techanly.entity.MaParams;
	import com.usfuture.techanly.proxy.LineProxy;
	import com.usfuture.util.DateTimeUtils;
	import com.usfuture.util.NumberFormat;
	
	import fl.controls.Button;
	import fl.controls.ComboBox;
	import fl.controls.ScrollBarDirection;
	import fl.controls.UIScrollBar;
	import fl.events.ComponentEvent;
	import fl.events.ScrollEvent;
	
	import flash.display.Sprite;
	import flash.display.StageDisplayState;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.external.ExternalInterface;
	import flash.geom.ColorTransform;
	import flash.text.TextField;
	import flash.ui.Keyboard;
	import flash.utils.Dictionary;
	import flash.utils.Timer;
	
	/**
	 * 技术分析容器
	 * @author zjy
	 */
	public class TechnicalAnalysisContainer extends Sprite implements ICallRequest
	{
		
		private var _lineTypeLabel:TextField;
		private var _zoomInButton:ZoomButton;
		private var _zoomOutButton:ZoomButton;
		private var _lineTypeComb:ComboBox;
		private var _maPriceShowLabel:TextField;
		private var _linePriceShowLabel:TextField;
		private var _lineCanvas:Canvas;
		private var _scrollBar:UIScrollBar;
		
		private var _lineData:Array;
		private var _lineDataCache:Dictionary;
		private var _lineProxy:LineProxy;
		private var _lineChart:LineChart;
		private var _maParamsArr:Array;
		
		private var _amountCanvas:Canvas;
		private var _amountChart:AmountChart;
		private var _maAmountShowLabel:TextField;
		private var _amountShowLabel:TextField;
		
		private var _scaleCanvas:Canvas;
		private var _scaleChart:ScaleChart;
		
		private var charts:Array=new Array;
		private var timer:Timer;
		
		private var isLineDataResponse:Boolean=true;
		private var _isInitResponse:Boolean=false;
		
		private var techProperty:AbstractTechProperty;
		
		private var rightLabelWidth:uint = 10;//右邊價格寬度
		
		
		
		//最新走势显示
		private var _lastInsShowLabel:TextField;
		private var _insInfo:InsInfo;
		private var isInsInfoDataResponse:Boolean=true;
		
		private var fullBtn:Button = new Button;
		
		public function TechnicalAnalysisContainer(width:Number,height:Number)
		{
			super();
			
			//初始化数据缓冲
			_lineDataCache = new Dictionary;
			//加载K线类型图
			_lineTypeLabel = new TextField;
			_lineTypeLabel.width = AbstractTechProperty.leftWidthX;
			_lineTypeLabel.height = 16;
			_lineTypeLabel.background = true;
			_lineTypeLabel.backgroundColor = 0xEA9FBD;
			_lineTypeLabel.selectable = false;
			_lineTypeLabel.text = AbstractTechProperty.lineTypeShow(AbstractTechProperty.lineType);
			_lineTypeLabel.visible = false;
			this.addChild(_lineTypeLabel);
			
			
			fullBtn.label = "全屏";
			fullBtn.addEventListener(MouseEvent.CLICK,toggleFullScreen);
			//this.addChild(fullBtn);
			
			
			//加载放大、缩小按钮
			_zoomInButton = new ZoomButton(ZoomButton.ZOOM_IN);
			_zoomOutButton = new ZoomButton(ZoomButton.ZOOM_OUT);
			_zoomInButton.x = AbstractTechProperty.leftWidthX+10;
			_zoomOutButton.x = AbstractTechProperty.leftWidthX+25;
			_zoomInButton.y = 4;
			_zoomOutButton.y = 4;
			_zoomInButton.addEventListener(MouseEvent.CLICK,zoomEvent);
			_zoomOutButton.addEventListener(MouseEvent.CLICK,zoomEvent);
			this.addChild(_zoomInButton);
			this.addChild(_zoomOutButton);
			//加载均线值显示label
			_maPriceShowLabel = new TextField;
			_maPriceShowLabel.selectable = false;
			_maPriceShowLabel.x = AbstractTechProperty.leftWidthX+25+20;
			_maPriceShowLabel.width = 400;
			this.addChild(_maPriceShowLabel);
			//加載下拉列表
			_lineTypeComb = new ComboBox;
			_lineTypeComb.setSize(100,20);
			_lineTypeComb.rowCount = 10;
//			_lineTypeComb.x = width - rightLabelWidth - 100 -100;
			_lineTypeComb.x = width - rightLabelWidth - 100;
			_lineTypeComb.addItem({label:AbstractTechProperty.lineTypeShow(AbstractTechProperty.LINE_ONE_MINUTE),data:AbstractTechProperty.LINE_ONE_MINUTE});
			_lineTypeComb.addItem({label:AbstractTechProperty.lineTypeShow(AbstractTechProperty.LINE_FIVE_MINUTE),data:AbstractTechProperty.LINE_FIVE_MINUTE});
//			_lineTypeComb.addItem({label:AbstractTechProperty.lineTypeShow(AbstractTechProperty.LINE_TEN_MINUTE),data:AbstractTechProperty.LINE_TEN_MINUTE});
			_lineTypeComb.addItem({label:AbstractTechProperty.lineTypeShow(AbstractTechProperty.LINE_FIFTEEN_MINUTE),data:AbstractTechProperty.LINE_FIFTEEN_MINUTE});
//			_lineTypeComb.addItem({label:AbstractTechProperty.lineTypeShow(AbstractTechProperty.LINE_TWENTY_MINUTE),data:AbstractTechProperty.LINE_TWENTY_MINUTE});
			_lineTypeComb.addItem({label:AbstractTechProperty.lineTypeShow(AbstractTechProperty.LINE_THIRTY_MINUTE),data:AbstractTechProperty.LINE_THIRTY_MINUTE});
//			_lineTypeComb.addItem({label:AbstractTechProperty.lineTypeShow(AbstractTechProperty.LINE_SIXTY_MINUTE),data:AbstractTechProperty.LINE_SIXTY_MINUTE});
			_lineTypeComb.addItem({label:AbstractTechProperty.lineTypeShow(AbstractTechProperty.LINE_DAILY),data:AbstractTechProperty.LINE_DAILY});
			_lineTypeComb.selectedIndex = 4;
			_lineTypeComb.addEventListener(Event.CHANGE,combChange);
			this.addChild(_lineTypeComb);
			
			//加载K线值显示label
			_linePriceShowLabel = new TextField;
			_linePriceShowLabel.selectable = false;
			_linePriceShowLabel.x = width - rightLabelWidth;
			_linePriceShowLabel.y = 15;
			_linePriceShowLabel.width = rightLabelWidth;
			_linePriceShowLabel.height = 200;
			_linePriceShowLabel.multiline = true;
			_linePriceShowLabel.visible = false;
			this.addChild(_linePriceShowLabel);
			
//			var lineCanvasWidth:Number = width - rightLabelWidth - 100;
			var lineCanvasWidth:Number = width - rightLabelWidth;
			var lineCanvasHeight:Number = height*0.6;
			
			//加载尺标
			_scaleCanvas =new Canvas(lineCanvasWidth,5,0x000000,0);
			_scaleCanvas.x = 0;
			_scaleCanvas.y = lineCanvasHeight + 5;
			_scaleChart = new ScaleChart(_scaleCanvas);
			charts.push(_scaleChart);
			this.addChild(_scaleCanvas);
			
			//  加载K线面板
			_lineCanvas = new Canvas(lineCanvasWidth,lineCanvasHeight,0x000000,0);
			_lineCanvas.x = 0;
			_lineCanvas.y = 22;
			this.addChild(_lineCanvas);
			_maParamsArr = new Array;
			var ma5:MaParams = new MaParams(6,0xCCB873);
			var ma10:MaParams = new MaParams(12,0x531D51);
			var ma20:MaParams = new MaParams(24,0x335E29);
			_maParamsArr.push(ma5);
			_maParamsArr.push(ma10);
			_maParamsArr.push(ma20);
			_lineChart = new LineChart(_lineCanvas,_maParamsArr);
			_lineChart.addEventListener(DataEvent.CURRENT_MOUSE_POSITION_DATA,currentMousePositiondataHandler);
			charts.push(_lineChart);

			//  加载滚动条 
			_scrollBar = new UIScrollBar;
			_scrollBar.direction = ScrollBarDirection.HORIZONTAL;
			_scrollBar.x = AbstractTechProperty.leftWidthX;
			_scrollBar.y = lineCanvasHeight + 22 - 1;
			_scrollBar.width = _lineCanvas.width - AbstractTechProperty.leftWidthX;
			_scrollBar.height = 16;
			_scrollBar.minScrollPosition = 0;
			_scrollBar.lineScrollSize = 10;
			_scrollBar.addEventListener(ScrollEvent.SCROLL,scroll);
			this.addChild(_scrollBar);

			
			//加载成交量面板 
			_amountCanvas = new Canvas(lineCanvasWidth,height - _scrollBar.y - _scrollBar.height,0x000000,0);
			_amountCanvas.x = 0;
			_amountCanvas.y = _scrollBar.y + _scrollBar.height -1;
			this.addChild(_amountCanvas);
			_maParamsArr = new Array;
			_maParamsArr.push(ma5);
			_maParamsArr.push(ma10);
			_maParamsArr.push(ma20);
			_amountChart = new AmountChart(_amountCanvas,_maParamsArr);
			_amountChart.addEventListener(DataEvent.CURRENT_MOUSE_POSITION_DATA,currentMousePositiondataHandler);
			charts.push(_amountChart);
			
			//加载成交量值显示面板
			_amountShowLabel = new TextField;
			_amountShowLabel.selectable = false;
			_amountShowLabel.x = width - rightLabelWidth;
			_amountShowLabel.y = lineCanvasHeight + 20 +22;
			_amountShowLabel.width = rightLabelWidth;
			this.addChild(_amountShowLabel);
			_maAmountShowLabel = new TextField;
			_maAmountShowLabel.selectable = false;
			_maAmountShowLabel.x = width - rightLabelWidth;
			_maAmountShowLabel.y = lineCanvasHeight + 20 + 22 + 10;
			_maAmountShowLabel.width = 105;
			_maAmountShowLabel.height = 200;
			_maAmountShowLabel.multiline = true;
			_maAmountShowLabel.visible = false;
			this.addChild(_maAmountShowLabel);
			
			_insInfo = new InsInfo;
			//添加走势显示label
			_lastInsShowLabel = new TextField;
			_lastInsShowLabel.multiline = true;
			_lastInsShowLabel.selectable = false;
			_lastInsShowLabel.x = width - 100;
			_lastInsShowLabel.y = 0;
//			_lastInsShowLabel.width = 180;
			_lastInsShowLabel.width = 0;
			_lastInsShowLabel.height = 300;
			this.addChild(_lastInsShowLabel);
			setInsInfoShowText(_insInfo);
			
			AbstractTechProperty.canvasWidth = _lineCanvas.width;
			
			this.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
			
			ExternalInterface.addCallback("responseLine",responseLine);
			ExternalInterface.addCallback("responseInsInfo",responseInsInfo);
		}
		
		/**
		 * 返回K线数据
		 * @param lineList K线数据
		 * @param lineType K线类型
		 */
		public function responseLine(lineList:Array,lineType:String):void{
			isLineDataResponse = true;
			isInitResponse = false;
			if(AbstractTechProperty.lineType!=lineType)
				return;
			if(!lineList) return;
			var lineData:Array = new Array;
			for each(var obj:Object in lineList){
				var line:Line = new Line;
				line.timestamp = DateTimeUtils.str2Date(obj.timestamp);
				line.openPrice = obj.openPrice;
				line.closePrice = obj.closePrice;
				line.highPrice = obj.highPrice;
				line.lowPrice = obj.lowPrice;
				line.volume = obj.amount;
				lineData.push(line);
			}
			

			if(!_lineData||_lineData.length==0){
				_lineData = lineData;
				var len:int = _lineData.length;
				for(var i:int=0;i<len;i++){
					if(i==0){
						Line(_lineData[i]).ycPrice = Line(_lineData[i]).openPrice;
						continue;
					}
					Line(_lineData[i]).ycPrice = Line(_lineData[i-1]).closePrice;
				}
				techProperty = TechPropertyFactory.createTechProperty(_lineData);
				for each(var chart:ITechAnlyChart in charts){
					chart.data = _lineData;
					chart.techProperty = techProperty;
				}
				setScrollBar();
			}else{
				//删除最后一个元素，并把新元素加到数组
				len = _lineData.length;
				_lineData.pop();
				var preLine:Line = _lineData[_lineData.length - 1];
				for each(var line:Line in lineData){
					line.ycPrice = preLine.closePrice;
					_lineData.push(line);
					preLine = line;
				}
				for each(var chart:ITechAnlyChart in charts){
					chart.data = _lineData;
				}
				if(len==_lineData.length)
					setScrollBar(false);
				else{
					if(techProperty.startPos==len){
						techProperty.startPos++;
						setScrollBar(true);
					}
				}
			}
			
			for each(var chart:ITechAnlyChart in charts){
				chart.repaint();
			}

			

		}
		
		private function setScrollBar(isSetMaxPos:Boolean=true):void{
			
			//对scrollbar进行赋值
			_scrollBar.lineScrollSize = techProperty.lineNum;
			_scrollBar.maxScrollPosition = _lineData.length;
			_scrollBar.minScrollPosition = techProperty.lineNum;
			if(isSetMaxPos)
				_scrollBar.scrollPosition = _scrollBar.maxScrollPosition;
		}

		
		/**
		 * 向左、右移动K线
		 * @param event
		 */
		private function scroll(event:ScrollEvent):void{
			techProperty.startPos = event.position;
		}
		
		/**
		 * 放大、缩小K线
		 * @param event
		 */
		private function zoomEvent(event:MouseEvent):void{
			switch (event.target){
				case _zoomInButton:
					techProperty.keyboardEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN,true,false,0,Keyboard.DOWN));
					break;
				case _zoomOutButton:
					techProperty.keyboardEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN,true,false,0,Keyboard.UP));
					break;
				default:break;
			}
			_scrollBar.lineScrollSize = techProperty.lineNum;
			_scrollBar.minScrollPosition = techProperty.lineNum;
		}
		
		private function mouseMoveHandler(event:MouseEvent):void{
			_lineChart.dispatchEvent(event);
			_amountChart.dispatchEvent(event);
		}
		
		/**
		 * 下拉列表改变事件 
		 * @param event
		 */
		private function combChange(event:Event):void{
			
			if(AbstractTechProperty.lineType == _lineTypeComb.selectedItem.data)
				return;
			
			if(_lineData)
				//把旧数据放入缓冲区
				_lineDataCache[AbstractTechProperty.lineType] = _lineData.slice(0,_lineData.length);
			
			AbstractTechProperty.lineType = _lineTypeComb.selectedItem.data;
		
			_lineTypeLabel.text = AbstractTechProperty.lineTypeShow(AbstractTechProperty.lineType);
			//把缓冲区里的数据拿出来 
			_lineData = _lineDataCache[AbstractTechProperty.lineType];
			
			if(!_lineData||_lineData.length==0){
				initCall();
				return;
			}
			techProperty = TechPropertyFactory.createTechProperty(_lineData);
			for each(var chart:ITechAnlyChart in charts){
				chart.data = _lineData;
				chart.techProperty = techProperty;
				chart.repaint();
			}
			setScrollBar();
		
		}

		
		/**
		 * 当前鼠标位置数据
		 * @param event
		 */
		private function currentMousePositiondataHandler(event:DataEvent):void{
			switch(event.target){
				case _lineChart:
					var line:Line = event.data.line;
					var mas:Object = event.data.mas;
					//显示K线值
					var linetxt:String = '';
					if(AbstractTechProperty.lineType==AbstractTechProperty.LINE_DAILY)
						linetxt+='<font color="#4C1650">日期:</font>'+DateTimeUtils.date2Str(line.timestamp,1).substr(0,10)+'<br>';
					else
						linetxt+='<font color="#4C1650">日期:</font>'+DateTimeUtils.date2Str(line.timestamp,1).substr(5,11)+'<br>';
					//linetxt+='<font color="#4C1650">time:</font>'+time+'<br>';
					linetxt+='<font color="#4C1650">收盤價:</font><font color="'+(line.closePrice>line.openPrice?'#7F2200':'#3A6E30')+'">'+NumberFormat.dynamicPrecisionStr(line.closePrice)+'</font><br>';
					linetxt+='<font color="#4C1650">漲跌:</font><font color="'+(line.closePrice>line.openPrice?'#7F2200':'#3A6E30')+'">'+(line.rise>0?'↑':'↓')+NumberFormat.dynamicPrecisionStr(Math.abs(line.rise))+'</font><br>';
					linetxt+='<font color="#4C1650">成交量:</font>'+int(line.volume)+'<br>';
					linetxt+='<font color="#4C1650">開盤價:</font><font color="#312122">'+NumberFormat.dynamicPrecisionStr(line.openPrice)+'</font><br>';
					linetxt+='<font color="#4C1650">最高價:</font><font color="'+(line.highPrice>line.openPrice?'#7F2200':'#3A6E30')+'">'+NumberFormat.dynamicPrecisionStr(line.highPrice)+'</font><br>';
					linetxt+='<font color="#4C1650">最低價:</font><font color="'+(line.lowPrice>line.openPrice?'#7F2200':'#3A6E30')+'">'+NumberFormat.dynamicPrecisionStr(line.lowPrice)+'</font><br>';
					_linePriceShowLabel.htmlText =linetxt;
					//显示ma均线值
					var matxt:String = '';
					for(var k:int=0;k<_maParamsArr.length;k++){
						var maParams:MaParams=_maParamsArr[k] as MaParams;
						if(mas[maParams.ma]){
							var ma:Number = mas[maParams.ma] as Number;
							var arrow:String = '';
							var color:String = '';
							if(ma>line.openPrice){
								arrow = '↑';
								color = '#7F2200';
							}
							else{
								arrow = '↓';
								color = '#3A6E30';
							}
							matxt+='<font color="#'+maParams.color.toString(16)+'">'+maParams.ma+'T</font>:<font color="'+color+'">'+NumberFormat.dynamicPrecisionStr(ma)+' '+arrow+'</font>   ';
						}
					}
					_maPriceShowLabel.htmlText = matxt;
					break;
				case _amountChart:
					var line:Line = event.data.line;
					var mas:Object = event.data.mas;
					//显示K线值
					var linetxt:String = '';
					linetxt+='<font color="#4C1650">成交量:</font><font color="#7F2200">'+int(line.volume)+'</font><br>';
					//_amountShowLabel.htmlText =linetxt;
					//显示ma均线值
					var matxt:String = '';
					for(var k:int=0;k<_maParamsArr.length;k++){
						var maParams:MaParams=_maParamsArr[k] as MaParams;
						if(mas[maParams.ma]){
							var ma:Number = mas[maParams.ma] as Number;
							matxt+='<font color="#'+maParams.color.toString(16)+'">'+maParams.ma+'T</font>:<font color="#431553">'+int(ma)+'</font><br>';
						} 
					}
					_maAmountShowLabel.htmlText = matxt;
					break;
				default:break;
			}
		}
		
		private function setInsInfoShowText(insInfo:InsInfo):void{
			var htmlTxt:String='<font size="14">';
			htmlTxt+='<B><font size="24" color="'+getColor(insInfo.newPrice,insInfo.ycPrice)+'">'+num2Str(insInfo.newPrice)+'</font><font size="12" color="'+getColor(insInfo.newPrice,insInfo.ycPrice)+'">'+' '+((insInfo.newPrice>=insInfo.ycPrice)?'△':'▽')+Math.round(insInfo.rise)+'</font></B><br>';
			//			htmlTxt+='<font color="#d68d48">委買價:</font><font color="#902131">8744</font><br>';
			//			htmlTxt+='<font color="#d68d48">委賣價:</font><font color="#902131">8745</font><br>';
			//			htmlTxt+='<font color="#938463">漲    跌:</font><font color="'+getColor(insInfo.newPrice,insInfo.ycPrice)+'">'+NumberFormat.twoPrecisionStr(insInfo.rise)+'</font><br>';
			//htmlTxt+= "<font color='#909090'>成交時間："+DateTimeUtils.date2Str(insInfo.timestamp,1)+"</font><br>"
			htmlTxt+='<font color="#d68d48">漲跌幅: </font><font color="'+getColor(insInfo.newPrice,insInfo.ycPrice)+'">'+NumberFormat.twoPrecisionStr(insInfo.risePer)+'%</font><br>';
			htmlTxt+='<font color="#d68d48">昨    收: </font><font color="#a2a091">'+num2Str(insInfo.ycPrice)+'</font><br>';
			htmlTxt+='<font color="#d68d48">開    盤: </font><font color="'+getColor(insInfo.openPrice,insInfo.ycPrice)+'">'+num2Str(insInfo.openPrice)+'</font><br>';
			htmlTxt+='<font color="#d68d48">最    高: </font><font color="'+getColor(insInfo.highPrice,insInfo.ycPrice)+'">'+num2Str(insInfo.highPrice)+'</font><br>';
			htmlTxt+='<font color="#d68d48">最    低: </font><font color="'+getColor(insInfo.lowPrice,insInfo.ycPrice)+'">'+num2Str(insInfo.lowPrice)+'</font><br>';
			htmlTxt+='<font color="#d68d48">總    量: </font><font color="#af8c52">'+num2Str(insInfo.allVolume)+'</font><br>';
			htmlTxt+='</font>';
			_lastInsShowLabel.htmlText= htmlTxt;

		}
		
		/**
		 * 根据价格与昨收价返回颜色
		 * @param price
		 * @param ycPrice
		 * @return 
		 */
		private function getColor(price:Number,ycPrice:Number):String{
			return price>ycPrice?'#c61b13':(price==ycPrice)?'#a2a091':'#2c6822'
		}
		
		/**
		 * 根据价格返回指定的格式
		 * @param price
		 * @return 
		 */
		private function num2Str(num:Number):String{
			return isNaN(num)||num==0?'----':num+'';
		}
		
		public function initCall():void{
			isLineDataResponse = false;
			isInitResponse = true;
			ExternalInterface.call("requestLine",AbstractTechProperty.lineType,'');
		}
		
		public function liveCall():void{
			requestInsInfo();
			
			if(!isLineDataResponse)
				return;
			isLineDataResponse = false;
			var lastTimestamp:String='';
			if(_lineData&&_lineData.length>0)
				lastTimestamp = DateTimeUtils.date2Str(Line(_lineData[_lineData.length-1]).timestamp);
			ExternalInterface.call("requestLine",AbstractTechProperty.lineType,lastTimestamp);
			
			
		}

		public function get isInitResponse():Boolean
		{
			return _isInitResponse;
		}

		public function set isInitResponse(value:Boolean):void
		{
			_isInitResponse = value;
			if(_isInitResponse)
				dispatchEvent(new BusyMaskEvent(BusyMaskEvent.SHOW));
			else
				dispatchEvent(new BusyMaskEvent(BusyMaskEvent.HIDE));
		}
		
		
		//须要整合
		public function requestInsInfo():void{
			if(isInsInfoDataResponse){
				isInsInfoDataResponse = false;
				ExternalInterface.call("requestInsInfo_line");
			}
		}
		
		/**
		 * 返回即时信息数据
		 * @param map
		 */
		public function responseInsInfo(map:Object):void{
			isInsInfoDataResponse = true;
			if(!map) return;
			_insInfo.timestamp = DateTimeUtils.str2Date(map.timestamp);
			_insInfo.ycPrice = map.ycPrice;
			_insInfo.openPrice = map.openPrice;
			_insInfo.newPrice = map.newPrice;
			_insInfo.highPrice = map.highPrice;
			_insInfo.lowPrice = map.lowPrice;
			_insInfo.allVolume = map.amount;
			setInsInfoShowText(_insInfo);
		}
		
		private function toggleFullScreen(event:MouseEvent):void {
			switch(stage.displayState) {
				case StageDisplayState.NORMAL:
					stage.displayState = StageDisplayState.FULL_SCREEN;    
					fullBtn.label = "退出全屏";
					//_lineCanvas = new Canvas(lineCanvasWidth,lineCanvasHeight,0x000000,0);
					
					break;
				case StageDisplayState.FULL_SCREEN:
				default:
					stage.displayState = StageDisplayState.NORMAL;   
					fullBtn.label = "全屏";
					break;
			}
		}  


	}
}